package main

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func preorderTraversal(root *TreeNode) []int {
	var res []int
	var Traversal func(root *TreeNode)
	Traversal = func(root *TreeNode) {
		if root == nil {
			return
		}
		res = append(res, root.Val)
		Traversal(root.Left)
		Traversal(root.Right)
	}
	Traversal(root)
	return res
}
func main() {

}
